#!/usr/bin/env python

"""

    SMS Utils for pyews application
    this used python-gammu library for sms 

"""

import gammu
from database import database

class smsutil:
    
    def send(self, smsmsg):
        try:
            modem = gammu.StateMachine()
            modem.ReadConfig()
            modem.Init()
            
            db = database()
            member = db.getMember()
            for row in member:
                smsconfig = {'Text': smsmsg , 'SMSC': {'Location': 1}, 'Number': row[0]}
                modem.SendSMS(smsconfig)
                print "Success sending sms"
            
        except:
            print "Failed sending sms message"
